public class demo1 {
    public static void main(String[] args) {
        int[] nums = {0,0,1,1,1,2,2,3,3,4};
        System.out.println(removeDuplicates(nums));

    }
    public static int removeDuplicates(int[] nums) {
        int count = 1;
        int n = nums.length;
        for(int i = 1;i < n;) {
            if(nums[i]==nums[i-1]) {
                delete(nums,nums[i]);
                n--;
            } else {
                count++;
                i++;
            }
        }
        return count;
    }
    public static void delete(int[] nums,int x) {
        for(int i = 0; i < nums.length;i++) {
            if(nums[i] == x) {
                for(;i < nums.length-1;i++) {
                    nums[i] = nums[i+1];
                }
            }
        }
    }
}
